package cn.csust.net2.manager.client.app;
import java.util.List;
import java.util.Map;

import cn.csust.net2.manager.client.chat.ChatPool;
import cn.csust.net2.manager.shared.po.Authority;
import cn.csust.net2.manager.shared.po.Module;
import cn.csust.net2.manager.shared.po.User;

import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.RootPanel;

public class App extends Viewport {
	//App主类持有所有类的引用，方便调用
	private static HeadPanel headPanel ;
	private AccordionPanel accordionPanel ;
	private TabSetPanel tabSetPanel ;
	protected HandlerManager eventBus;
	protected Map<Module,List<Authority>> map;
	//当前是第几学期
	public static String nowTerm;

	public static  User user;
	public static ChatPool chatPool;

	public App(HandlerManager eventBus,Map<Module,List<Authority>> map) {
		this.eventBus = eventBus;
		this.map = map;
		init();

	}
	
	/**
	 * 初始化
	 */
	private void init() {
		this.setBounds(0, 0, RootPanel.getBodyElement().getClientWidth(),RootPanel.getBodyElement().getClientHeight());
		setLayout(new BorderLayout());
		setStyleAttribute("padding", "5px");
		addPanel();
	}
	private void addPanel(){
		headPanel = new HeadPanel(this);
		tabSetPanel = new TabSetPanel(this);
		accordionPanel = new AccordionPanel(this);
		
		add(headPanel,headPanel.getLayoutInfo());
		add(accordionPanel,accordionPanel.getLayoutInfo());
		add(tabSetPanel,tabSetPanel.getLayoutInfo());
	}
	
	public static User getUser() {
		return user;
	}
	public static void setUser(User user) {
		App.user = user;
	}
	public static ChatPool getChatPool() {
		return chatPool;
	}
	public static void setChatPool(ChatPool chatPool) {
		App.chatPool = chatPool;
	}
	
	public TabSetPanel getTabSetPanel() {
		return tabSetPanel;
	}
	public static HeadPanel getHeadPanel() {
		return headPanel;
	}
	
	public void setTabSetPanel(TabSetPanel tabSetPanel) {
		this.tabSetPanel = tabSetPanel;
	}
	
	public native static void refrash()
	/*-{
	
		$wnd.location.reload();
	
	}-*/;

}
